<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 引入vue.js -->
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
</head>
<body>
    <div id="app">
        <!-- 插值模板语法 -->
        <!-- 里面写的是setup return的属性名 -->
        {{ x }}
        <br/>
        {{ y }}
        <br/>
        <!-- 事件绑定指令 -->
        <button @click="fun">点击修改message</button>
    </div>
    <script>
        // 解构赋值
        const { createApp, ref } = Vue
        createApp({
            setup() {
                let a = 1
                const message = ref('Hello vue!')
                setTimeout(() => {
                    a = 2
                    message.value = '这里的文字变化了吗'
                }, 5000)
                const fun = () => {
                    console.log('方法被执行了吗')
                    message.value = new Date().toLocaleTimeString()
                }
                // ES6的对象简写
                // 属性名和值的变量名称一致时，可以省略属性值
                return {
                    x: a,
                    y: message,
                    fun: fun
                }
            }
        }).mount('#app')
    </script>
</body>
</html>